﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserAdd.aspx.cs" Inherits="Invoicing.sys.UserAdd" %>
<style type="text/css" media="screen">
.my-uploadify-button {
	background:none;
	border: none;
	text-shadow: none;
	border-radius:0;
}

.uploadify:hover .my-uploadify-button {
	background:none;
	border: none;
}

.fileQueue {
	width: 400px;
	height: 150px;
	overflow: auto;
	border: 1px solid #E5E5E5;
	margin-bottom: 10px;
}
</style>
<script src="../js/json2.js"></script>
<script src="../js/jquery.ztree.core-3.5.min.js"></script>
<script src="../js/jquery.ztree.excheck-3.5.min.js"></script>
<script src="../js/jquery.ztree.exedit-3.5.min.js"></script>
<script type="text/javascript">


    //文件上传成功后的操作
    function uploadSuccess(file, data, response) {
        var result = JSON.parse(data);
        if (result.as == 200) {
            $("#txdisplay").attr("src", "../TxFile/" + result.meg);
            $("#txtimg").val(result.meg);
        }
    }
    //文件上传完成后
    function uploadComplete(queueData) {
        //var msg = "The total number of files uploaded: " + queueData.uploadsSuccessful + "<br/>" + "The total number of errors while uploading: " + queueData.uploadsErrored + "<br/>" + "The total number of bytes uploaded: " + queueData.queueBytesUploaded + "<br/>" + "The average speed of all uploaded files: " + queueData.averageSpeed;
        if (queueData.uploadsErrored) {
           // alertMsg.error("上传失败");
        } else {
            //alertMsg.correct("上传成功");
        }
    }
    //默认获取角色选择值
    var roleselval = $("#rid").val();
    $("#sel_to_tabrole").val(roleselval);
    loadtrees(roleselval)
    function selectval(obj)
    {
        var temps = $(obj).val();
        //alert(temps)
        $("#sel_to_tabrole").val(temps);
    }


    var myTree;

    //定义树形菜单事件
    function zTreeOnCheck(event, treeId, treeNode) {

        var nodes = myTree.getCheckedNodes(true);
        var str = "";
        $.each(nodes, function (i, data) {
            str = str + data.id.toString() + ","
        });
        $("#treeids").val(str);
    };

    var setting = {
        check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onCheck: zTreeOnCheck
        }

    };

    var code;
    function showCode(str) {
        if (!code) code = $("#code");
        code.empty();
        code.append("<li>" + str + "</li>");
    }



    //加载去除角色的菜单信息
    function loadtrees(obj) {
            $.ajax({
                type: 'post',
                data: 'rid='+obj+'&type=1000',
                url: 'AJAX/MenuTree.ashx',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    myTree = $.fn.zTree.init($("#treeDemo"), setting, data.treedata);
                }
            });

        }

</script>

<div class="pageContent">    
        <form id="form1" method="post" action="AJAX/Userinfo.ashx" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone)">
        <input type="hidden" name="action" value="add" />
        <input type="hidden" name="txtimg" id="txtimg" value="default.jpg" />
        <input type="hidden" id="treeids" name="treeids" />
        <input type="hidden" id="sel_to_tabrole" value="-1" />
        <input  type="hidden" name="txtpower" value=""/>

        <!-- tab最大外部框架-->
        <div class="tabs" currentIndex="0" eventType="click">
        
        <div class="tabsHeader">
			<div class="tabsHeaderContent">
				<ul>
					<li><a href="javascript:;"><span>基本信息</span></a></li>
			        <li><a href="javascript:;"><span>扩展权限</span></a></li>
				</ul>
			</div>
		</div> <!--tab头部信息-->

        <div class="tabsContent" layoutH="70">
        <div id="tab_base">
        <div class="pageFormContent" >
        <fieldset>
		<legend>用户基本信息</legend>
                <p>                                       
                    <label>用户名称：</label>
                    <input type="text" name="txtusername" size="30" maxlength="50"  class="required" alt=""  />
                </p>
                <p>
                    <label>用户密码：</label>
                    <input type="password" name="txtpassword" size="30" maxlength="50"  class="required" alt="" />
                </p>
                <p>
                    <label>用户姓名：</label>
                    <input type="text" name="txtrueName" size="30" maxlength="50"  class="required" alt="" />
                </p>
                <p>
                    <label>用户邮箱：</label>
                    <input type="text" name="txtemail" size="30" maxlength="50"  class="required email" alt="" />
                </p>
                <p>
                    <label>用户电话：</label>
                    <input type="text" name="txtmobile" size="30" maxlength="50"  class="phone" alt="" />
                </p>
              
                <p>
                    <label>用户部门：</label>
                    <select name="upid" id="upid" style="width:184px" class="combox">
                      
                       <%
                           
                       foreach  (ZY.Model.Tab_DeptInfo item in DeptList)
                       {
                           
                       %>  
                              <option  value="<%= item.dp_id %>"><%=item.dp_namme %></option>
                                
                       <%

                       }    
                        
                       %>
                            
                    </select>

                </p>
                <p>
                    <label>用户角色：</label>
                    <select name="rid" id="rid" class="combox" style="width:184px" onchange="selectval(this)">
                       <%
                           
                           foreach (ZY.Model.Tab_RoleInfo item in RoleList)
                       {
                           
                       %>  
                              <option  value="<%= item.rid %>"><%=item.r_name %></option>
                                
                       <%

                       }    
                        
                       %>
                    </select>

                </p>
                <p>
                    <label>用户级别：</label>
                    <select name="uleve" id="uleve" style="width:184px" class="combox">
                        <option  value="0">高级</option>
                        <option  value="1">中级</option>
                        <option  value="2">低级</option>
                    </select>

                </p>

                 <p>
                    <label>用户职位：</label>
                    <select name="upostion" id="upostion" style="width:184px" class="combox">
                        
                    <%
                           
                        foreach (ZY.Model.Tab_Poistion item in PoistionList)
                       {
                           
                       %>  
                              <option  value="<%= item.pid %>"><%=item.p_name %></option>
                                
                       <%

                       }    
                        
                       %>
                    </select>

                </p>
                <p>
                    <label>用户状态：</label>
                    <select name="ddlstate" id="ddlstate" style="width:184px" class="combox">
                        <option  value="1">启用</option>
                        <option  value="0">禁用</option>
                     
                    </select>

                </p>

                  <p>
                    <label>用户地址：</label>
                    <input type="text" name="txtaddres" size="30" maxlength="50"     alt="" />
                </p>
              <p>
                    <label>用户备注：</label>
                    <input type="text" name="txtnote" size="30" maxlength="50"     alt="" />
                </p>
                

</fieldset>

        <fieldset>
		<legend>形象照片</legend>

        <div id="tximgs">
               <table style="width:220px; border:0" style="text-align:right" >
                   <tr >
                       <td> <img alt="tx" id="txdisplay" src="/TxFile/default.jpg" width="100" height="100" /></td>
                       <td valign="bottom">
            <input id="testFileInput" type="file" name="image" uploaderOption="{
			swf:'uploadify/scripts/uploadify.swf',
			uploader:'/AJAX/UploadFile.ashx',
			buttonText:'请选择文件',
			fileSizeLimit:'400KB',
			fileTypeDesc:'*.jpg;*.jpeg;*.gif;*.png;',
			fileTypeExts:'*.jpg;*.jpeg;*.gif;*.png;',
			auto:true,
			multi:false,
			onUploadSuccess:uploadSuccess,
			onQueueComplete:uploadComplete
		}"
	/>
                       </td>
                   </tr>

               </table>
        </div>
        
</fieldset>
        </div>
        </div>
        <div id="tab_ajax">
              <ul id="treeDemo" class="ztree">
        </ul>
        </div>
     
        </div>


        </div>





            <div class="formBar">
                <ul>
                    <li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交</button></div></div></li>
                    <li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
                </ul>
            </div>
        </form>
    </div>
